package com.ruoyi.web.controller.linkage.linkageStrategy;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.linkage.Vo.LinkageEventVo;
import com.ruoyi.linkage.domain.LinkageEventSpecialRecord;
import com.ruoyi.linkage.service.ILinkageEventSpecialRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 联动事件特情记录Controller
 *
 * @author pengjie
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/linkage/specialRecord")
public class LinkageEventSpecialRecordController extends BaseController
{
    @Autowired
    private ILinkageEventSpecialRecordService linkageEventSpecialRecordService;

    /**
     * 查询联动事件特情记录列表
     */
    @PreAuthorize("@ss.hasPermi('linkage:specialRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list( LinkageEventVo linkageEventVo)
    {
        startPage();
        List<LinkageEventSpecialRecord> list = linkageEventSpecialRecordService.queryLinkageEventSpecialRecordList(linkageEventVo);
        return getDataTable(list);
    }

    /**
     * 导出联动事件特情记录列表
     */
    @PreAuthorize("@ss.hasPermi('linkage:specialRecord:export')")
    @Log(title = "联动事件特情记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LinkageEventSpecialRecord linkageEventSpecialRecord)
    {
        List<LinkageEventSpecialRecord> list = linkageEventSpecialRecordService.selectLinkageEventSpecialRecordList(linkageEventSpecialRecord);
        ExcelUtil<LinkageEventSpecialRecord> util = new ExcelUtil<LinkageEventSpecialRecord>(LinkageEventSpecialRecord.class);
        util.exportExcel(response, list, "联动事件特情记录数据");
    }

    /**
     * 获取联动事件特情记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('linkage:specialRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(linkageEventSpecialRecordService.selectLinkageEventSpecialRecordById(id));
    }

    /**
     * 新增联动事件特情记录
     */
    @PreAuthorize("@ss.hasPermi('linkage:specialRecord:add')")
    @Log(title = "联动事件特情记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LinkageEventSpecialRecord linkageEventSpecialRecord)
    {
        return toAjax(linkageEventSpecialRecordService.insertLinkageEventSpecialRecord(linkageEventSpecialRecord));
    }

    /**
     * 修改联动事件特情记录
     */
    @PreAuthorize("@ss.hasPermi('linkage:specialRecord:edit')")
    @Log(title = "联动事件特情记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LinkageEventSpecialRecord linkageEventSpecialRecord)
    {
        return toAjax(linkageEventSpecialRecordService.updateLinkageEventSpecialRecord(linkageEventSpecialRecord));
    }

    /**
     * 删除联动事件特情记录
     */
    @PreAuthorize("@ss.hasPermi('linkage:specialRecord:remove')")
    @Log(title = "联动事件特情记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(linkageEventSpecialRecordService.deleteLinkageEventSpecialRecordByIds(ids));
    }
}
